package com.yzt.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.yzt.base.kit.Base;
import com.yzt.log.aop.SysOperateLog;
import com.yzt.user.entity.Info;
import com.yzt.user.service.IInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Y
 * @since 2020-12-08
 */
@RestController
@RequestMapping("/user/info")
@Api(tags = "用户接口")
public class InfoController {
	@Autowired
	private IInfoService infoService;

	@GetMapping("list")
	@ApiOperation("用户列表")
	@SysOperateLog
	@PreAuthorize("hasAuthority('sys:mananger')")
	public Base<PageInfo<Info>> list(int page, int limit) {
		return infoService.userList(page, limit);
	}

	@GetMapping("list1")
	@ApiOperation("用户列表")
	@SysOperateLog
	@PreAuthorize("hasAuthority('sys:mananger1')")
	public Base<PageInfo<Info>> list1(int page, int limit) {
		return infoService.userList(page, limit);
	}

	@PutMapping("")
	@ApiOperation("保存用户信息")
	@SysOperateLog
	public Base<Object> save(Info info) {
		return infoService.addInfo(info);
	}

}
